package com.kgc.scd.controller;

import com.alibaba.fastjson.JSON;
import com.kgc.scd.constant.CommonConstant;
import com.kgc.scd.service.WebSensitiveWordService;
import com.kgc.scd.util.*;
import com.kgc.scd.vo.SensitiveWord;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * Created On : 2022/11/18.
 * <p>
 * Author : 刘慧枫
 * <p>
 * Description: 敏感词测试入口
 */
@Slf4j
@RestController
@Api(tags = "敏感词测试入口，版本1.0")
public class WebSensitiveWordController {

    @Autowired
    private WebSensitiveWordService webSensitiveWordService;


    /**
     * @author : zhukang
     * @date   : 2022/11/12
     * @param  : [java.lang.String]
     * @return : com.kgc.sbt.util.RequestResult<java.lang.String>
     * @description : 测试搜索中的敏感词
     */
    @GetMapping("/testSensitiveWordWeb")
    @ApiOperation(value = "测试搜索中的敏感词",notes = "基于mybatis-plus,redis")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "searchKey",value = "敏感词")
    })
    public RequestResult<String> testSensitiveWord(@RequestParam String searchKey){

        return webSensitiveWordService.testSensitiveWordUseFeign(searchKey);
    }

    /**
     * @author : zhukang
     * @date   : 2022/11/12
     * @param  : [java.lang.String]
     * @return : com.kgc.sbt.util.RequestResult<java.lang.String>
     * @description : 测试添加敏感词，并将敏感词同步到redis中，也可以作为系统敏感词初始化功能
     */
    @PostMapping("/addSensitiveWordWeb")
    @ApiOperation(value = "测试添加敏感词",notes = "基于mybatis-plus,redis")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "tid",value = "敏感词分类"),
            @ApiImplicitParam(name = "word",value = "敏感词")
    })
    public RequestResult<String> addSensitiveWord(@RequestParam Integer tid, @RequestParam String word){

        return webSensitiveWordService.addSensitiveWordUseFeign(tid,word);
    }
}
